package com.leaf.spring.y201907.day11.lamdba;

import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 利用java8新特性过滤map中null的value
 *@Title:  
 *@Description:  
 *@Author: leaf  
 *@Since:2019年7月11日  
 *@Version:1.1.0
 */
public class MapConvertTest {
	
	public static void main(String[] args) {

		Map<String, Object> map = new HashMap<>();

		map.put("a", null);
		map.put("b", true);
		map.put("c", "");
		map.put("d", 'l');
		map.put("e", 1);

		System.out.println(map.entrySet());
		
		Map<String, Object> collect = map.entrySet().stream().filter(e -> null != e.getValue()).collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue()));

		System.out.println(collect);

	}

}
